#include <cvirte.h>		
#include <userint.h>
#include <ansi_c.h>
#define SIZE 9
#define nr 'n'
#define bl 'b'
#define ab ' '
#define x '.'
#define tmp 'X'
static int image;
static int noir;
static int blanc;
static int panelHandle;
int tab[SIZE+1][SIZE]= { {ab,'1','2','3','4','5','6','7','8'},
						  {'1',ab,ab,ab,ab,ab,ab,ab,ab},
 				 		  {'2',ab,ab,ab,ab,ab,ab,ab,ab},		
 						  {'3',ab,ab,ab,ab,ab,ab,ab,ab},
 				 		  {'4',ab,ab,ab,bl,nr,ab,ab,ab},
						  {'5',ab,ab,ab,nr,bl,ab,ab,ab},
						  {'6',ab,ab,ab,ab,ab,ab,ab,ab},
 					      {'7',ab,ab,ab,ab,ab,ab,ab,ab},
						  {'8',ab,ab,ab,ab,ab,ab,ab,ab},
					  };

int main (int argc, char *argv[])
{
	if (InitCVIRTE (0, argv, 0) == 0)
		return -1;	/* out of memory */
	if ((panelHandle = LoadPanel (0, "othello.uir", PANEL)) < 0)
		return -1;
	DisplayPanel (panelHandle);
	RunUserInterface ();
	DiscardPanel (panelHandle);
	return 0;
  
}

int CVICALLBACK fermer_prog (int panel, int event, void *callbackData,
		int eventData1, int eventData2)
{
	switch (event)
	{
		case EVENT_CLOSE:

			break;
	}
	return 0;
}

int CVICALLBACK gerer_table (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	Point cell;
	switch (event)
	{
		case EVENT_COMMIT:
			QuitUserInterface (0);
			break;
		case EVENT_LEFT_CLICK_UP:
			GetActiveTableCell (PANEL, PANEL_TABLE, &cell);
		
			GetBitmapFromFile ("image.jpg", &noir);
			GetBitmapFromFile ("images.jpg", &blanc);
			
			GetBitmapFromFile ("Collines.jpg", &image);
			SetTableCellVal (PANEL, PANEL_TABLE, cell, image);
			break;
	}
	return 0;
}
